package data.analysis.grammar.symbol;

public class Symbol {
	private String name;
	private Type type;
	private Scope defining;
	
	public Symbol(String name, Type type, Scope defining) {
		this.name = name;
		this.type = type;
		this.defining = defining;
	}
	
	public String getName() {
		return name;
	}
	
	public Type getType() {
		return type;
	}
	
	public Scope getScope() {
		return defining;
	}
	
	@Override
	public boolean equals(Object o) {
		if (o == null) {
			return false;
		}
		if (!o.getClass().equals(this.getClass())) {
			return false;
		}
		
		Symbol s = (Symbol)o;
		return s.getName().equals(this.getName()) && s.getType().equals(this.getType())
				&& (s.getScope() == null) ? this.getScope() == null : s.getScope().equals(this.getScope());
	}
	
	@Override
	public int hashCode() {
		return getName().hashCode() + getType().hashCode() + ((getScope() == null) ? 0 : getScope().hashCode());
	}
}
